<div class="content-section introduction">
    <div class="feature-intro">
        <h1>ScrollTop</h1>
        <p>ScrollTop gets displayed after a certain scroll position and used to navigates to the top of the page quickly.</p>
    </div>
    <app-demoActions github="scrolltop" stackblitz="scrolltop-demo"></app-demoActions>
</div>

<div class="content-section implementation">
    <div class="card">
        <h5>Window</h5>
        <p>Scroll down the page to display the ScrollTo component.</p>
        <p-scrollTop></p-scrollTop>

        <h5>Element</h5>
        <p-scrollPanel [style]="{width: '250px', height: '200px'}">
            <p>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                Vitae et leo duis ut diam.
                Ultricies mi quis hendrerit dolor magna eget est lorem. Amet consectetur adipiscing elit ut.
                Nam libero justo laoreet sit amet. Pharetra massa massa ultricies mi quis hendrerit dolor magna.
                Est ultricies integer quis auctor elit sed vulputate. Consequat ac felis donec et. Tellus orci ac auctor augue mauris.
                Semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Tincidunt arcu non sodales neque sodales.
                Metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices. Sodales ut etiam sit amet nisl purus.
                Cursus sit amet dictum sit amet. Tristique senectus et netus et malesuada fames ac turpis egestas.
                Et tortor consequat id porta nibh venenatis cras sed. Diam maecenas ultricies mi eget mauris.
                Eget egestas purus viverra accumsan in nisl nisi. Suscipit adipiscing bibendum est ultricies integer.
                Mattis aliquam faucibus purus in massa tempor nec.
            </p>
            <p-scrollTop target="parent" styleClass="custom-scrolltop" [threshold]="100" icon="pi pi-arrow-up"></p-scrollTop>
        </p-scrollPanel>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
            <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;ScrollTopModule&#125; from 'primeng/scrolltop';
</app-code>

                <h5>Getting Started</h5>
				<p>Without any configuration, ScrollTop listens window scroll.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-scrollTop&gt;&lt;/p-scrollTop&gt;
</app-code>

                <h5>Threshold</h5>
				<p>When the vertical scroll position reaches a certain value, ScrollTop gets displayed. This value is
					defined with the <i>threshold</i> property that defaults to 400.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-scrollTop [threshold]="200"&gt;&lt;/p-scrollTop&gt;
</app-code>

                <h5>Target Element</h5>
				<p>ScrollTop can also be assigned to its parent element by setting <i>target</i> as "parent".</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;div style="height: 400px; overflow: auto"&gt;
    Content that overflows to container
    &lt;p-scrollTop target="parent"&gt;&lt;/p-scrollTop&gt;
&lt;/div&gt;
</app-code>

                <h5>Properties</h5>
                <div class="doc-tablewrapper">
					<table class="doc-table">
						<thead>
                            <tr>
                                <th>Name</th>
                                <th>Type</th>
                                <th>Default</th>
                                <th>Description</th>
                            </tr>
						</thead>
						<tbody>
                            <tr>
                                <td>target</td>
                                <td>string</td>
                                <td>window</td>
                                <td>Target of the ScrollTop, valid values are "window" and "parent".</td>
                            </tr>
                            <tr>
                                <td>threshold</td>
                                <td>number</td>
                                <td>400</td>
                                <td>Defines the threshold value of the vertical scroll position of the target to toggle the visibility.</td>
                            </tr>
                            <tr>
                                <td>icon</td>
                                <td>string</td>
                                <td>pi pi-chevron-up</td>
                                <td>Icon to display.</td>
                            </tr>
							<tr>
                                <td>behavior</td>
                                <td>string</td>
                                <td>smooth</td>
                                <td>Defines the scrolling behavi, "smooth" adds an animation and "auto" scrolls with a jump.</td>
                            </tr>
                            <tr>
                                <td>style</td>
                                <td>object</td>
                                <td>null</td>
                                <td>Inline style of the component.</td>
                            </tr>
                            <tr>
                                <td>styleClass</td>
                                <td>string</td>
                                <td>null</td>
                                <td>Style class of the component.</td>
                            </tr>
						</tbody>
					</table>
                </div>
                
				<h5>Styling</h5>
				<p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming</a> page.</p>
				<div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Element</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>p-scrolltop</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>p-scrolltop-sticky</td>
                            <td>Container element when attached to its parent.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Dependencies</h5>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/scrolltop" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-scrolltop-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>
            
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;h5&gt;Window&lt;/h5&gt;
&lt;p&gt;Scroll down the page to display the ScrollTo component.&lt;/p&gt;
&lt;p-scrollTop&gt;&lt;/p-scrollTop&gt;

&lt;h5&gt;Element&lt;/h5&gt;
&lt;p-scrollPanel [style]="&#123;width: '250px', height: '200px'&#125;"&gt;
    &lt;p&gt;
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
        Vitae et leo duis ut diam.
        Ultricies mi quis hendrerit dolor magna eget est lorem. Amet consectetur adipiscing elit ut.
        Nam libero justo laoreet sit amet. Pharetra massa massa ultricies mi quis hendrerit dolor magna.
        Est ultricies integer quis auctor elit sed vulputate. Consequat ac felis donec et. Tellus orci ac auctor augue mauris.
        Semper feugiat nibh sed pulvinar proin gravida hendrerit lectus a. Tincidunt arcu non sodales neque sodales.
        Metus aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices. Sodales ut etiam sit amet nisl purus.
        Cursus sit amet dictum sit amet. Tristique senectus et netus et malesuada fames ac turpis egestas.
        Et tortor consequat id porta nibh venenatis cras sed. Diam maecenas ultricies mi eget mauris.
        Eget egestas purus viverra accumsan in nisl nisi. Suscipit adipiscing bibendum est ultricies integer.
        Mattis aliquam faucibus purus in massa tempor nec.
    &lt;/p&gt;
    &lt;p-scrollTop target="parent" styleClass="custom-scrolltop" [threshold]="100" icon="pi pi-arrow-up"&gt;&lt;/p-scrollTop&gt;
&lt;/p-scrollPanel&gt;
</app-code>
<app-code lang="css" ngNonBindable ngPreserveWhitespaces>
:host ::ng-deep .custom-scrolltop&#123;
    width: 2rem;
    height: 2rem;
    border-radius: 4px;
    background-color: var(--primary-color);

    &:hover &#123;
        background-color: var(--primary-color);
    &#125;

    .p-scrolltop-icon &#123;
        font-size: 1rem;
        color: var(--primary-color-text);
    &#125;
&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-scrolltop-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
    </p-tabView>
</div>